from selenium import webdriver
import time
from pprint import pprint

driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
time.sleep(1)

# 获取所有cookie
pprint(driver.get_cookies())

# 通过键获取cookie的信息
pprint(driver.get_cookie('PSTM'))

# 新增cookie,必须有name和value
dict = {'name':'hello','value':'123456'}
driver.add_cookie(dict)
pprint(driver.get_cookie('hello'))

# 删除指定cookie
driver.delete_cookie('hello')
pprint(driver.get_cookie('hello'))

# 删除所有的cookie
driver.delete_all_cookies()
pprint(driver.get_cookie('PSTM'))